package com.example.project.controller;

import com.example.project.common.Result;
import com.example.project.service.ImageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/api/image")
@Slf4j
public class ImageController {

    @Autowired
    private ImageService imageService;

    @PostMapping("/upload")
    public Result<?> upload(@RequestParam("file") MultipartFile file) {
        return imageService.upload(file);
    }

    /*
    @GetMapping("/view/{imageId}")
    public void getImage(@PathVariable Long imageId, HttpServletResponse response) {
        // ...
    }
    */
}
